
<div id="app" style="overflow: auto;width:100%;">
    <section class="content-header">
        <h1>
            <small>订单统计</small>
        </h1>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-header with-border">

                        <div class="box-tools">
                            <div class="btn-group pull-right" style="margin-right: 100px">
                                <a style="margin:0px 5px;" href="/admin/order/exportOrderExcel{{$excel_url}}&xxhf=1" class="btn btn-sm btn-default" target="_blank" title="先享后付测评导出"> <span class="hidden-xs">先享后付测评导出</span></a>
                            </div>
                        </div>
                        <div class="box-tools">
                            <div class="btn-group pull-right" style="margin-left: 50px">
                                <a style="margin:0px 5px;" href="/admin/order/exportOrderExcel{{$excel_url}}" class="btn btn-sm btn-default" target="_blank" title="导出"> <span class="hidden-xs">导出</span></a>
                            </div>
                        </div>

                        <span>

    <a class="btn btn-sm btn-primary grid-refresh" title="刷新"><i class="fa fa-refresh"></i><span class="hidden-xs"> 刷新</span></a>


    <div class="btn-group" style="margin-right: 10px" data-toggle="buttons">
        <label class="btn btn-sm btn-dropbox shangjia-filter-btn" title="先享后付">
            <span class="hidden-risk">先享后付</span>
        </label>
    </div>


    <div class="btn-group" style="margin-right: 10px" data-toggle="buttons">
        <label class="btn btn-sm btn-dropbox shaixuan-filter-btn" title="筛选">
            <input type="checkbox"><i class="fa fa-filter"></i><span class="hidden-xs">筛选</span>
        </label>
    </div>
  </span>

                    </div>

                    <!--   筛选开始   -->
                    <div class="box-header with-border hide" id="filter-box">
                        <form action="/admin/order/excelOrders" class="form-horizontal" pjax-container method="get">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="box-body">
                                        <div class="fields-group">

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">订单状态</label>
                                                <div class="col-sm-8">
                                                    <select class="form-control order_status" id="order_status" name="order_status" style="width: 100%;">
                                                        <option value="-1"></option>
                                                        <option value="0">订单未完成</option>
                                                        <option value="1">待审核</option>
                                                        <option value="2">待发货</option>
                                                        <option value="3">已发货</option>
                                                        <option value="4">还款中</option>
                                                        <option value="5">已完成</option>
                                                        <option value="6">订单取消</option>
                                                        <option value="7">拒绝</option>
                                                        <option value="8">逾期中</option>
                                                        <option value="9">异常退货</option>
                                                        <option value="10">交易关闭</option>

                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">订单来源</label>
                                                <div class="col-sm-8">
                                                    <select class="form-control order_comefrom" id="order_comefrom" name="order_comefrom" style="width: 100%;">
                                                        <option value="-1"></option>
                                                        @if($channel)
                                                            @foreach($channel as $k=>$v)
                                                                <option value="{{$k}}">{{$v}}</option>
                                                            @endforeach
                                                        @endif

                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">订单类型</label>
                                                <div class="col-sm-8">
                                                    <select class="form-control order_type" id="order_type" name="order_type" style="width: 100%;">
                                                        <option value=""></option>
                                                        <option value="1">分期购买</option>
                                                        <option value="2">全款购买</option>
                                                    </select>
                                                </div>
                                            </div>


                                            <div class="form-group">
                                                <label class="col-sm-2 control-label"> 订单号</label>
                                                <div class="col-sm-8">
                                                    <div class="input-group input-group-sm">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-pencil"></i>
                                                        </div>

                                                        <input type="text" class="form-control order_id" placeholder="订单号" name="order_id" value="@if(!empty($where['order_id'])) {{$where['order_id']}} @endif">
                                                    </div>    </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label"> 商品名称</label>
                                                <div class="col-sm-8">
                                                    <div class="input-group input-group-sm">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-pencil"></i>
                                                        </div>

                                                        <input type="text" class="form-control goods_name" placeholder="商品名称" name="goods_name" value="@if(!empty($where['goods_name'])) {{$where['goods_name']}} @endif">
                                                    </div>    </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">手机号</label>
                                                <div class="col-sm-8">
                                                    <div class="input-group input-group-sm">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-pencil"></i>
                                                        </div>

                                                        <input type="text" class="form-control user_phone" placeholder="手机号" name="user_phone" value="@if(!empty($where['user_phone'])) {{$where['user_phone']}} @endif">
                                                    </div>    </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">姓名</label>
                                                <div class="col-sm-8">
                                                    <div class="input-group input-group-sm">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-pencil"></i>
                                                        </div>

                                                        <input type="text" class="form-control user_name" placeholder="姓名" name="user_name" value="@if(!empty($where['user_name'])) {{$where['user_name']}} @endif">
                                                    </div>    </div>
                                            </div>




                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">下单时间</label>
                                                <div class="col-sm-8" style="width: 390px">
                                                    <div class="input-group input-group-sm">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-calendar"></i>
                                                        </div>
                                                        <input type="text" class="form-control" id="create_time_start"   name="start_time" value="@if(!empty($where['start_time'])) {{$where['start_time']}} @endif">
                                                        <span class="input-group-addon" style="border-left: 0; border-right: 0;">-</span>
                                                        <input type="text" class="form-control" id="create_time_end"   name="end_time" value="@if(!empty($where['end_time'])) {{$where['end_time']}} @endif">
                                                    </div>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-body -->

                            <div class="box-footer">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="col-md-2"></div>
                                        <div class="col-md-8">
                                            <div class="btn-group pull-left">
                                                <button class="btn btn-info submit btn-sm"><i
                                                            class="fa fa-search"></i>&nbsp;&nbsp;搜索</button>
                                            </div>
                                            <div class="btn-group pull-left " style="margin-left: 10px;">
                                                <a href="/admin/order/excelOrders" class="btn btn-default btn-sm"><i
                                                            class="fa fa-undo"></i>&nbsp;&nbsp;重置</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <!--筛选结束-->




                    <!-- /.box-header -->
                    <!--数据列表开始   -->
                    <div class="box-body table-responsive no-padding" style="overflow: auto; ">
                        <table class="table table-hover"   style="width:150%;max-width: 150%;">
                            <thead >
                            <tr >
                                <th> </th>
                                {{--<th>商品id<a class="fa fa-fw fa-sort" href="http://www.laras.com/admin/goods/goodsList?_sort%5Bcolumn%5D=goods_id&_sort%5Btype%5D=desc"></a></th>--}}
                                <th  > 订单状态</th>
                                <th  >订单来源</th>
                                <th >订单号</th>
                                <th  >先享后付风控</th>

                                <th  >商品名称</th>
                                <th >信用分</th>

                                <th  >客户名称</th>
                                <th  >客户手机号</th>
                                <th  >收货地址</th>
                                <th>下单时间</th>
                                <th  >总期数</th>
                                <th  >剩余期数</th>
                                <th  >剩余还款金额</th>
                                <th  >第三方订单号</th>

                                <th  >快递公司</th>
                                <th  >快递单号</th>
                                <th  >备注信息</th>
                                <th  >操作</th>
                            </tr>
                            </thead>

                            <tbody>

                            @if (!empty($data['data']))
                                @foreach($data['data'] as $v)
                                    <tr >
                                        <td >
                                            <input type="radio" name="a" class="grid-row-radio" data-id="{{ $v['order_id']}}" />
                                        </td>
                                        <td >
                                            {{$v['order_status']}}
                                        </td>
                                        <td >
                                            {{$v['order_comefrom']}}
                                        </td>
                                        <td >
                                            {{$v['order_id']}}
                                        </td>
                                        <td class="xxhf{{$v['order_id']}}">
                                            {{$v['log_xxhf']}}
                                        </td>
                                        <td >
                                            {{$v['goods_name']}}
                                        </td>

                                        <td >
                                            {{$v['zm_credit_score']}}
                                        </td>
                                        <td >
                                            {{$v['user_name']}}
                                        </td>
                                        <td >
                                            {{$v['user_phone']}}
                                        </td>
                                        <td style="width:200px;">
                                            {{$v['order_address']}}
                                        </td>
                                        <td >
                                            {{$v['order_create_time']}}
                                        </td>
                                        <td >
                                            {{$v['order_tenancy_term']}}
                                        </td>
                                        <td >
                                            {{$v['order_repay_period']}}
                                        </td>
                                        <td >
                                            {{$v['order_rema_amount_pay']}}
                                        </td>
                                        <td >
                                            {{$v['zm_order_no']}}
                                        </td>

                                        <td >
                                            {{$v['express']}}
                                        </td>
                                        <td >
                                            {{$v['exp_number']}}
                                        </td>
                                        <td style="width:100px;">
                                            {{$v['order_remarks']}}
                                        </td>

                                        <td >
                                            <a onclick="popShow(this)" href="javascript:;"   data-href="/admin/order/orderShow?order_id={{$v['order_id']}}">查看</a>
                                            | <a onclick="popShow(this)" href="javascript:;"   data-href="/admin/order/orderStagesInfo?order_id={{$v['order_id']}}">账单</a>
                                        </td>

                                    </tr>
                                @endforeach
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <!--数据列表结束-->



                    <!-- 分页开始    -->
                    <div class="box-footer clearfix">
                        @if($data['data'])
                            从 <b>{{$data['from']}}</b> 到 <b>{{$data['to']}}</b> ，总共 <b>{{$data['total']}}</b> 条
                            <ul class="pagination pagination-sm no-margin pull-right">
                                <!-- Previous Page Link -->
                                @if($data['page_list'])
                                    <li class="page-item @if($data['current_page']==1) disabled @endif ">
                                        @if($data['current_page']>1)
                                            <a class="page-link" data-href="{{$data['page_url']}}&page={{$data['up_page']}}" rel="next">&laquo;</a>
                                        @else
                                            <span class="page-link">&laquo;</span>
                                        @endif</li>
                                    @foreach($data['page_list'] as $v)
                                        @if($v=='...')
                                            <li class="page-item disabled"><span class="page-link">{{$v}}</span></li>
                                        @endif
                                        @if($v==$data['current_page'])
                                            <li class="page-item active"><span class="page-link">{{$v}}</span></li>
                                        @elseif($v!='...')
                                            <li class="page-item"><a class="page-link" data-href="{{$data['page_url']}}&page={{$v}}">{{$v}}</a></li>
                                        @endif
                                    @endforeach
                                    <li class="page-item @if($data['current_page']==$data['last_page']) disabled @endif ">
                                        @if($data['current_page']<$data['last_page'])
                                            <a class="page-link" data-href="{{$data['page_url']}}&page={{$data['next_page']}}" rel="next">&raquo;</a>
                                        @else
                                            <span class="page-link">&raquo;</span>
                                        @endif</li>
                                @endif
                            </ul>

                            <label class="control-label pull-right" style="margin-right: 10px; font-weight: 100;">
                                <small>显示</small>&nbsp;
                                <select class="input-sm grid-per-pager" name="per-page">
                                    <option value="{{$data['page_url']}}&per_page=10" >10</option>
                                    <option value="{{$data['page_url']}}&per_page=20" selected>20</option>
                                    <option value="{{$data['page_url']}}&per_page=30" >30</option>
                                    <option value="{{$data['page_url']}}&per_page=50" >50</option>
                                    <option value="{{$data['page_url']}}&per_page=100" >100</option>
                                </select>
                                &nbsp;<small>条</small>
                            </label>
                        @else
                            <div style="text-align: center;margin:20px;">未查到数据</div>
                        @endif
                    </div>
                    <!-- 分页结束    -->

                    <!-- /.box-body -->
                </div>
            </div>
        </div>

    </section>
</div>

<script data-exec-on-popstate>

    //多选id数组
    var selectedRows = function () {
        var selected = [];
        $('.grid-row-radio:checked').each(function(){
            selected.push($(this).data('id'));
        });
        return selected;
    }
    $(function () {
        $("#order_status").val("@if(!empty($where['order_status'])){{$where['order_status']}}@endif");
        $("#order_type").val("@if(!empty($where['order_type'])){{$where['order_type']}}@endif");
        $("#order_comefrom").val("@if(!empty($where['order_comefrom'])){{$where['order_comefrom']}}@endif");
        //日历插件
        $('#create_time_start').datetimepicker({"format":"YYYY-MM-DD HH:mm:ss","locale":"zh-CN"});
        $('#create_time_end').datetimepicker({"format":"YYYY-MM-DD HH:mm:ss","locale":"zh-CN","useCurrent":false});
        $("#create_time_start").on("dp.change", function (e) {
            $('#create_time_end').data("DateTimePicker").minDate(e.date);
        });
        $("#create_time_end").on("dp.change", function (e) {
            $('#create_time_start').data("DateTimePicker").maxDate(e.date);
        });








        //tr选中样式控制
        $('.grid-row-checkbox').iCheck({checkboxClass:'icheckbox_minimal-blue'}).on('ifChanged', function () {
            if (this.checked) {
                $(this).closest('tr').css('background-color', '#ffffd5');
            } else {
                $(this).closest('tr').css('background-color', '');
            }
        });



        $('.grid-select-all').iCheck({checkboxClass:'icheckbox_minimal-blue'});

        $('.grid-select-all').on('ifChanged', function(event) {
            if (this.checked) {
                $('.grid-row-checkbox').iCheck('check');
            } else {
                $('.grid-row-checkbox').iCheck('uncheck');
            }
        });







        //刷新
        $('.grid-refresh').on('click', function() {
            $.pjax.reload('#pjax-container');
            toastr.success('刷新成功 !');
        });

        //搜索
        $('.shaixuan-filter-btn').unbind('click');
        $('.shaixuan-filter-btn').click(function (e) {
            if ($('#filter-box').is(':visible')) {
                $('#filter-box').addClass('hide');
            } else {
                $('#filter-box').removeClass('hide');
            }
        });
        @if($where)
        $('#filter-box').removeClass('hide');
        @endif


        //改变分页量
        $('.grid-per-pager').on("change", function(e) {
            $.pjax({url: this.value, container: '#pjax-container'});
        });

        //分页
        $("a.page-link").click(function(e){
            var url=$(this).attr('data-href');
            $.pjax({url:url, container: '#pjax-container'});
        });

        $(".hidden-risk").click(function (e) {
            if(selectedRows().length==0){
                swal('请选择订单', '', 'error'); return false;
            }
            var order_id=selectedRows()[0];
            $.ajax({
                url:"/admin/order/xxhf",
                data:{order_id:order_id,_token:LA.token},
                type:'post',
                dataType:'json',
                success:function(m){
                    console.log(m);
                    if(m.status==1){
                        toastr.success(m.message);
                        $(".xxhf"+order_id).html(m.data.res);
                    }else{
                        swal(m.message, '', 'error');
                    }
                }
            });
        });

    });




    function popShow(e){
        var url=$(e).attr('data-href');
        $("#popLayer").show();
        $("#popBox").show();
        $("#popFrame").attr('src',url);
        console.log(url);
    }
    function closeFrame(e) {
        $("#popBox").css('display','none');
        $("#popFrame").attr('src','');
        $('#popLayer').css('display','none');
    }
</script>